﻿using LxBasic;
using System;
using System.Windows.Media.Media3D;

namespace LxCFD
{
    public struct PlaneFactory
    {
        public PlaneFactory()
        {
            Positions = null;
            TriangleIndices = null;
            triInds = new int[30][];
            for (int i1 = 0; i1 < triInds.Length; i1++)
            {
                int pointCount = i1 + 3;
                int triCount = pointCount - 2;
                int[] ti = triInds[i1] = new int[triCount * 3];
                for (int i2 = 0; i2 < triCount; i2++)
                {
                    int i23 = i2 * 3;
                    ti[i23] = 0;
                    ti[i23 + 1] = i2 + 1;
                    ti[i23 + 2] = i2 + 2;
                }
            }
        }
        public Vector3d[] Positions;
        public int[] TriangleIndices;
        private int[][] triInds;
        public void Create(Vector3d[] points)
        {
            Positions = points;
            TriangleIndices = triInds[points.Length - 3];
        }
    }
}